/*
 * Copyright 2011 Angel Sanadinov
 *
 * This file is part of VBox WMI.
 *
 * VBox WMI is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * VBox WMI is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with VBox WMI.  If not, see <http://www.gnu.org/licenses/>.
 */

package Utilities;

/**
 * This class contains various constants and enumerations used throughout the
 * application.
 *
 * @author Angel Sanadinov
 */
public class Constants
{
    /** Sentinel Constant: Invalid user ID */
    public static final int INVALID_USER_ID = 0;
    /** Sentinel Constant: Invalid server ID */
    public static final int INVALID_SERVER_ID = 0;
    /** Sentinel Constant: Invalid event ID */
    public static final int INVALID_EVENT_ID = 0;
    /** Sentinel Constant: Invalid numeric resource ID */
    public static final int INVALID_NUMERIC_RESOURCE_ID = 0;
    /** Sentinel Constant: Invalid NIC number */
    public static final int INVALID_NIC_NUMBER = -1;

    /** DB Resource type: Invalid resource */
    public static final int DB_RESOURCE_INVALID = 0;
    /** DB Resource type: Virtual Machine */
    public static final int DB_RESOURCE_VIRTUAL_MACHINE = 1;
    /** DB Resource type: Virtual Medium*/
    public static final int DB_RESOURCE_VIRTUAL_MEDIUM = 2;
    /** DB Resource type: Virtual Network */
    public static final int DB_RESOURCE_VIRTUAL_NETWORK = 3;

    /** DB User account level: Disabled (cannot log in) */
    public static final int DB_USER_ACCOUNT_LEVEL_DISABLED = 0;
    /** DB User account level: Normal */
    public static final int DB_USER_ACCOUNT_LEVEL_NORMAL = 1;
    /** DB User account level: User manager (can modify other users) */
    public static final int DB_USER_ACCOUNT_LEVEL_MANAGER = 2;
    /** DB User account level: System owner (can perform all actions) */
    public static final int DB_USER_ACCOUNT_LEVEL_OWNER = 3;

    /** Virtual resource types */
    public enum VirtualResourceType
    {
        /** Invalid resource type */
        INVALID,
        /** Resource type: Virtual Machine */
        MACHINE,
        /** Resource type: Virtual Medium */
        MEDIUM,
        /** Resource type: Virtual Network */
        NETWORK
    }

    /** Servlet context attribute name for Logs Manager */
    public static final String CONTEXT_LOGS_MANAGER = "logsManager";
    /** Servlet context attribute name for Database Manager */
    public static final String CONTEXT_DATABASE_MANAGER = "databaseManager";
    /** Servlet context attribute name for Permissions Manager */
    public static final String CONTEXT_PERMISSIONS_MANAGER = "permissionsManager";
    /** Servlet context attribute name for Sessions Manager */
    public static final String CONTEXT_SESSIONS_MANAGER = "sessionsManager";
    /** Servlet context attribute name for VirtualBox Connections Manager */
    public static final String CONTEXT_VBOX_CONNECTIONS_MANAGER = "connectionsManager";

    /** Log severity level: Error/Exception */
    public static final String LOG_SEVERITY_ERROR = "E";
    /** Log severity level: Warning */
    public static final String LOG_SEVERITY_WARNING = "W";
    /** Log severity level: User Login */
    public static final String LOG_SEVERITY_USER_LOGIN = "L";
    /** Log severity level: Information */
    public static final String LOG_SEVERITY_INFORMATION = "I";
    /** Log severity level: Debugging */
    public static final String LOG_SEVERITY_DEBUG = "D";

    /** SQL Error Code: No Error */
    public static final int SQL_NO_ERROR = 0;
    /** SQL Error Code: Unknown Error */
    public static final int SQL_ERROR_UNKNOWN = 1;
    /** SQL Error Code: Attempting to insert an entry that already exists */
    public static final int SQL_ERROR_ENTRY_EXISTS  = 2;
    /** SQL Error Code: An update operation has failed (entry might not exist) */
    public static final int SQL_ERROR_NOT_UPDATED = 3;
    /** SQL Error Code: A remove operation has failed (entry might not exist) */
    public static final int SQL_ERROR_NOT_REMOVED = 4;

    /** Actions for changing the state of a virtual machine. */
    public enum MachineStateChangeAction
    {
        /** Invalid state change action */
        INVALID_ACTION,
        /** State change action: Power Up */
        POWER_UP,
        /** State change action: Power Down */
        POWER_DOWN,
        /** State change action: Reset */
        RESET,
        /** State change action: Save */
        SAVE,
        /** State change action: Pause */
        PAUSE,
        /** State change action: Resume */
        RESUME,
        /** State change action: ACPI Power (send ACPI power off signal) */
        ACPI_POWER,
        /** State change action: ACPI Sleep (send ACPI sleep signal) */
        ACPI_SLEEP
    }

    /** Available actions for storage devices management */
    public enum StorageDeviceAction
    {
        /** Invalid device action */
        INVALID_ACTION,
        /** Action: Create new storage device and attach it */
        CREATE,
        /** Action: Attach an existing storage device */
        ATTACH,
        /** Action: Detach an existing storage device */
        DETACH,
        /** Action: Replace an existing storage device with another */
        REPLACE
    }

    /** Type of remote sessions initiated with virtual machines */
    public enum MachineRemoteSessionType
    {
        /** Invalid remote session type */
        INVALID_TYPE,
        /** Remote session type: GUI (the machine GUI will be shown on host) */
        GUI,
        /** Remote session type: VRDP (no GUI is shown on host; accessed only via VRDP) */
        VRDP,
        /** Remote session type: SDL (SDL GUI is shown on host) */
        SDL;

        @Override
        public String toString()
        {
            return name().toLowerCase();
        }
    }

    /** Machine snapshots management actions */
    public enum MachineSnapshotManagementAction
    {
        /** Invalid snapshot action */
        INVALID_ACTION,
        /** Snapshot action: Create new snapshot */
        CREATE,
        /** Snapshot action: Remove existing snapshot */
        REMOVE,
        /** Snapshot action: Restore existing snapshot */
        RESTORE,
        /** Snapshot action: Modify snapshot details */
        MODIFY
    }

    /** Network types */
    public enum NetworkType
    {
        /** Invalid network type */
        INVALID_TYPE,
        /** Network type: Host-Only and Bridged */
        HOST_ONLY,
        /** Network type: Internal */
        INTERNAL
    }

    /** Types of requested resources */
    public enum ResourceRequestType
    {
        /** Invalid resource type */
        INVALID_RESOURCE,
        /** Resource type: Single resource is requested */
        SINGLE_RESOURCE,
        /** Resource type: Multiple resources are requested */
        MULTIPLE_RESOURCES
    }

    /** ID types used for a requested resource */
    public enum ResourceIdType
    {
        /** Invalid ID type */
        INVALID_ID,
        /** Resource type: number ID (servers, users, logs) */
        NUMERIC_ID,
        /** Resource type: UUID (machines, media, networks) */
        UUID
    }

    /** Types of limits for constraining logs retrieval */
    public enum LogsRetrievalLimit
    {
        /** Invalid limit */
        INVALID_LIMIT,
        /** Limit type: No limit (all available logs are retrieved) */
        NO_LIMIT,
        /** Limit type: Server ID
         * (all available logs for specified server are retrieved) */
        SERVER_ID,
        /** Limit type: Initiator ID 
         * (all available logs for the specified user are retrieved) */
        INITIATOR_ID,
        /** Limit type: Severity 
         * (all available logs with specified severity are retrieved) */
        SEVERITY
    }

    /** Types of limits for virtual resource retrieval */
    public enum VirtualResourcesRetrievalLimit
    {
        /** Invalid limit */
        INVALID_LIMIT,
        /** Limit type: No limit (all available resources are retrieved) */
        NO_LIMIT,
        /** Limit type: Owner ID
         * (all available resources with the specified owner are retrieved) */
        OWNER_ID
    }

    /** Types of miscellaneous data requests */
    public enum MiscellaneousRequestType
    {
        /** Invalid request type */
        INVALID_REQUEST,
        /** Request type: Guest OS types */
        GUEST_OS_TYPES,
        /** Request type: Medium formats */
        MEDIUM_FORMATS
    }

    /** Exception types thrown by the application */
    public enum ApplicationExceptionType
    {
        /** Invalid exception type */
        INVALID_EXCEPTION,
        /** Exception type: VirtualBox (a VirtualBox server generated the exception) */
        VIRTUALBOX_EXCEPTION,
        /** Exception type: Application (the application generated the exception) */
        APPLICATION_EXCEPTION
    }

    /** Object types returned by a compression wrapper */
    public enum CompressionWrapperReturnedObject
    {
        /** Object type: None */
        NONE,
        /** Object type: Writer (PrintWriter) */
        WRITER,
        /** Object type: Stream (InputStream?) */
        STREAM
    }

    /** Compression algorithms used by the compression filter */
    public enum FilterCompressionAlgorithm
    {
        /** Algorithm: None used */
        NONE,
        /** Algorithm: GZIP */
        GZIP
    }

    /** System logging levels */
    public enum SystemLoggingLevel
    {
        /** Level: None (no system logging is performed) */
        NONE,
        /** Level: Debug (full system logging is performed) */
        DEBUG,
        /** Level: Default (normal system logging is performed) */
        DEFAULT
    }

    /** Reporting filter logging levels */
    public enum ReportingLoggingLevel
    {
        /** Level: None (nothing is logged by the reporting filter) */
        NONE,
        /** Level: Request (only requests are logged) */
        REQUEST,
        /** Level: Response (only responses are logged) */
        RESPONSE,
        /** Level Request & Response (requests and responses are logged) */
        REQUEST_RESPONSE
    }

    /** Results from request submissions */
    public enum SendingRequestResult
    {
        /** Result type: OK (the submission was successful) */
        OK,
        /** Result type: Invalid HTTP data (invalid request/response objects) */
        INVALID_HTTP_DATA,
        /** Result type: Invalid request (invalid request data supplied) */
        INVALID_REQUEST,
        /** Result type: Invalid service (invalid service requested) */
        INVALID_SERVICE,
        /** Result type: Invalid dispatcher (failed to retrieve dispatcher for service) */
        INVALID_DISPATCHER
    }

    /**
     * User account levels
     * 
     * @see Constants#DB_USER_ACCOUNT_LEVEL_DISABLED
     * @see Constants#DB_USER_ACCOUNT_LEVEL_NORMAL
     * @see Constants#DB_USER_ACCOUNT_LEVEL_MANAGER
     * @see Constants#DB_USER_ACCOUNT_LEVEL_OWNER
     */
    public enum UserAccountLevel
    {
        /** Account level: Disabled */
        DISABLED,
        /** Account level: Normal */
        NORMAL,
        /** Account level: Manager */
        MANAGER,
        /** Account level: Owner */
        OWNER
    }

    private Constants(){}
}
